package com.ruoyi.familyManagement.service.impl;

import com.ruoyi.familyManagement.domain.China;
import com.ruoyi.familyManagement.domain.vo.FamilyInfoVO;
import com.ruoyi.familyManagement.mapper.DocFamilyAddressMapper;
import com.ruoyi.familyManagement.service.IDocFamilyAddressService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.*;

@Service
public class DocFamilyAddressImpl implements IDocFamilyAddressService {

    @Autowired
    private DocFamilyAddressMapper docFamilyAddressMapper;

    /**
     * 查询所有省份（pid=0 且 id!=0）
     */
    @Override
    public List<China> getAllProvince() {
        return docFamilyAddressMapper.selectAllProvinces();
    }

    /**
     * 根据省份id查询城市
     */
    @Override
    public List<China> getAllCities(Integer provinceId) {
        return docFamilyAddressMapper.selectCitiesByProvinceId(provinceId);
    }

    /**
     * 根据城市id查询地区
     */
    @Override
    public List<China> getAllDistricts(Integer cityId) {
        return docFamilyAddressMapper.selectDistrictsByCityId(cityId);
    }

    /**
     * 修改家庭信息
     *
     * @param familyInfoVO 家庭信息对象
     * @return boolean 修改成功返回true，否则返回false
     */
    @Override
    public boolean updateFamilyInfo(Long userId, FamilyInfoVO familyInfoVO) {
        return docFamilyAddressMapper.updateFamilyInfo(userId, familyInfoVO) > 0;
    }

}
